package com.wang.vedio.adapter.index;

import android.view.View;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.wang.vedio.R;
import com.wang.vedio.net.entity.VipBean;

import java.util.List;

public class VipAdapter extends BaseQuickAdapter<VipBean, BaseViewHolder> {
    public VipAdapter(int layoutResId, @Nullable List<VipBean> data) {
        super(layoutResId, data);
    }

    private int selectPosition = -1;

    public void setSelectPosition(int position) {
        this.selectPosition = position;
        notifyDataSetChanged();
    }

    @Override
    protected void convert(BaseViewHolder helper, VipBean item) {
        helper.setText(R.id.vipName, item.getVipName())
                .setText(R.id.vipDay, item.getVipDay()>10000?"（永久）":"（" + item.getVipDay() + "天）")
                .setText(R.id.vipPrice, "￥" + item.getVipPrice())
                .setText(R.id.vipOldPrice, "原价：￥" + item.getVipOldPrice());

        View view = helper.getView(R.id.vipLinear);
        if(helper.getAdapterPosition() == selectPosition){
            view.setBackgroundResource(R.drawable.btn_white_10_shape);
        }else{
            view.setBackgroundResource(R.drawable.btn_yellow_10_line);
        }
    }
}
